<template>
  <div class="aotoBox">
    <van-nav-bar title="巡检记录详情" fixed class="titleStyle" left-arrow @click-left="onClickLeft" />
    <div class="publicBox">
      <div class="myDetailTopBox">
        <div class="myDetailTopBoxCont">
          <h1>
            <span>工单号：{{ dataObject.workOrderNo }}</span>
          </h1>
          <ul class="detailsUl">
            <li>
              <div><span>不合格数：</span><b>{{ dataObject.unqualifiedNum }}</b></div>
            </li>
            <li>
              <div><span>检验人：</span><b>{{ dataObject.checkUserName }}</b></div>
            </li>
            <li>
              <div><span>检验时间：</span><b>{{ dataObject.checkTime }}</b></div>
            </li>
            <li>
              <div><span>检验结果：</span>
                <b v-if="dataObject.result == 1">结果分开算</b>
                <b v-else-if="dataObject.result == 2">整批合格</b>
                <b v-else>整批不合格</b>
              </div>
            </li>
            <li style="width:100%;">
              <div><span>不合格原因：</span><b>{{ dataObject.unqualifiedReason }}</b></div>
            </li>
            <li style="width:100%;">
              <div><span>备注：</span><b>{{ dataObject.remark }}</b></div>
            </li>
            <li class="imgDivStyle">
              <div class="divImg">
                <span>附件：</span>
                <b style="height:100%;">
                  <van-cell-group v-if="dataObject.patrolFileList">
                    <van-uploader v-model="dataObject.patrolFileList" max-count="3" :deletable="false" disabled />
                  </van-cell-group>
                </b>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <h1>质量控点</h1>
      <div class="qualityBox">
        <quality-control :item-list="itemList" />
      </div>
    </div>
  </div>
</template>
<script>
import qualityControl from '../../components/qualityControlPre'
import { imgBig } from '../../../../utils/function'
import { ImagePreview } from 'vant'
export default {
  name: 'FirstCheckDetails',
  components: { qualityControl },
  data () {
    return {
      itemList: [],
      listData: [],
      dataObject: {}
    }
  },
  computed: {

  },
  watch: {
  },
  mounted () {
    this.getDatas()
  },
  methods: {
    getImg (images, index) {
      ImagePreview({
        images: this.listData,
        showIndex: true,
        loop: false,
        startPosition: index
      })
    },
    async getDatas () {
      const res = await this.$axios.get(`/dobo-product/pad/patrol/record/detail?id=${this.$route.query.id}`)
      if (res.data.code === 200) {
        if (res.data.data.itemList) {
          if (res.data.data.patrolFileList.length > 0) {
            res.data.data.patrolFileList = imgBig(res.data.data.patrolFileList)
            this.listData.push(res.data.data.patrolFileList)
          }
          res.data.data.itemList.forEach(item => {
            if (item.itemFileEntityList.length > 0) {
              item.itemFileEntityList = imgBig(item.itemFileEntityList)
              this.listData.push(item.itemFileEntityList)
            }
          })
        }
        this.dataObject = res.data.data
        this.itemList = res.data.data.itemList
      }
    },
    // 返回
    onClickLeft () {
      this.$router.push('./patrolInspectionRecord')
    }
  }
}
</script>

<style lang='scss' scoped>
h1{
  height: 40px;
  line-height: 40px;
  font-weight: normal;
  text-align: center;
  background: #eeee;
}
.qualityBox{
  height: calc(100% - 320px);
  overflow-y: auto;
}
</style>

